package ch02.demo;


import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.junit.jupiter.api.Test;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

public class XMLDemo2 {

    public XMLDemo2() throws IOException, SAXException, ParserConfigurationException {
        DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();

        DocumentBuilder db=dbf.newDocumentBuilder();
        Document doc=db.parse("src/main/java/ch02/demo/Demo2.xml");

        NodeList list=doc.getElementsByTagName("pubDate");
        Element pubDateElement= (Element) list.item(0);
        String pubDate=pubDateElement.getFirstChild().getNodeValue();
    }
}
